package com.handlePicture;

import com.saas.sys.log.Logger;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO;

public class HandlePicture
{
  Logger log = new Logger(this);

  public boolean handlePic(int paramInt1, int paramInt2, String paramString1, String paramString2)
    throws IOException
  {
    File localFile1 = new File(paramString2);
    BufferedImage localBufferedImage1 = ImageIO.read(localFile1);
    int i = localBufferedImage1.getWidth(null);
    int j = localBufferedImage1.getHeight(null);
    double d = 0.0D;
    if (paramString1.equals("middle"))
      d = 0.7D;
    if (paramString1.equals("small"))
      d = 0.4D;
    int k = (int)(i * d);
    int m = (int)(j * d);
    BufferedImage bi = new BufferedImage(k, m, 4);
    bi.getGraphics().drawImage(localBufferedImage1, 0, 0, k, m, null);
    String str1 = paramString2.substring(0, paramString2.lastIndexOf("."));
    String str2 = paramString2.substring(paramString2.lastIndexOf("."), paramString2.length());
    String str3 = str1 + "_" + paramString1 + str2;
    File localFile2 = new File(str3);
    FileOutputStream fos = new FileOutputStream(localFile2);
    JPEGImageEncoder jie = JPEGCodec.createJPEGEncoder(fos);
    jie.encode(bi);
    fos.close();
    return true;
  }
}

